* Title : De Micheli (2018) Replication Code
* Date : August 2017
* Article title : The Racialized Effects of Social Programs in Brazil
* Journal : Latin American Politics and Society
* Author : David De Micheli

clear
set more off
cd "INSERT FILE PATH HERE"

do 1-lapop-cleanup.do
do 2-lapop-merge.do
clear

* LAPOP REPLICATION CODE

use "lapop-brazil-2008_14.dta", clear

ssc install cem
cem race2(0 1) wealth1(1 2 3 4 5) educ(4 8 11 15) age age2 female(0 1) partyid(0 1 2 3 4) year(2008 2010 2012 2014) region(1 2 3 4 5), treatment(bf1)

* Tables 5 and 6 - Participation
logit vote6 bf1 race2 [iweight=cem_weights]
logit vote6 bf1 race2 wealth1 educ age age2 female i.partyid [iweight=cem_weights]
logit vote6 bf1 race2 wealth1 educ age age2 female i.partyid i.year i.region [iweight=cem_weights]
logit vote6 c.bf1##c.race2 wealth1 educ age age2 female i.partyid i.year i.region [iweight=cem_weights]
margins, dydx(bf1) 					/* Average marginal effect of CCT */
margins, at(bf1=(0 1) race2=(0 1)) 	/* Predicted probabilities by race and CCT */
margins, dydx(bf1) at(race2=(0 1)) 	/* Marginal effect of CCT over race */
margins, dydx(race2) at(bf1=(0 1)) 	/* Marginal effect of Race over CCT */

* Tables 7 and 8 - Vote choice
logit vote7 bf1 race2 [iweight=cem_weights]
logit vote7 bf1 race2 wealth1 educ age age2 female i.partyid [iweight=cem_weights]
logit vote7 bf1 race2 wealth1 educ age age2 female i.partyid i.year i.region [iweight=cem_weights]
logit vote7 c.bf1##c.race2 wealth1 educ age age2 female i.partyid i.year i.region [iweight=cem_weights]
margins, dydx(bf1) 					/* Average marginal effect of CCT */
margins, at(bf1=(0 1) race2=(0 1)) 	/* Predicted probabilities by race and CCT */
margins, dydx(bf1) at(race2=(0 1)) 	/* Marginal effect of CCT over race */
margins, dydx(race2) at(bf1=(0 1)) 	/* Marginal effect of Race over CCT */


* IBOPE REPLICATION CODE

use "ibope.dta", clear

cem race2(0 1) educ(1 2 3 4 5) income(1 2 3 4 5 6 7) female(0 1) age age2 region(1 2 3 4 5), treatment(bf)

* Round 1 - Participation

logit vote1a bf race2 [iweight=cem_weights]
logit vote1a bf race2 educ income female age age2 [iweight=cem_weights]
logit vote1a bf race2 educ income female age age2 i.region [iweight=cem_weights]
logit vote1a c.bf##c.race2 educ income female age age2 i.region [iweight=cem_weights]

logit vote1a c.bf##c.race2 educ income female age age2 i.region [iweight=cem_weights]
margins, dydx(bf) 					/* Average marginal effect of CCT */
margins, at(bf=(0 1) race2=(0 1)) 	/* Predicted probabilities by race and CCT */
margins, dydx(bf) at(race2=(0 1)) 	/* Marginal effect of CCT over race */
margins, dydx(race2) at(bf=(0 1)) 	/* Marginal effect of Race over CCT */

* Round 2 - Participation

logit vote2a bf race2 [iweight=cem_weights]
logit vote2a bf race2 educ income female age age2 [iweight=cem_weights]
logit vote2a bf race2 educ income female age age2 i.region [iweight=cem_weights]
logit vote2a c.bf##c.race2 educ income female age age2 i.region [iweight=cem_weights]

logit vote2a c.bf##c.race2 educ income female age age2 i.region [iweight=cem_weights]
margins, dydx(bf) 					/* Average marginal effect of CCT */
margins, at(bf=(0 1) race2=(0 1)) 	/* Predicted probabilities by race and CCT */
margins, dydx(bf) at(race2=(0 1)) 	/* Marginal effect of CCT over race */
margins, dydx(race2) at(bf=(0 1)) 	/* Marginal effect of Race over CCT */

* Round 1 - Vote Choice

logit vote1b bf race2 [iweight=cem_weights]
logit vote1b bf race2 educ income female age age2 [iweight=cem_weights]
logit vote1b bf race2 educ income female age age2 i.region [iweight=cem_weights]
logit vote1b c.bf##c.race2 educ income female age age2 i.region [iweight=cem_weights]

logit vote1b c.bf##c.race2 educ income female age age2 i.region [iweight=cem_weights]
margins, dydx(bf) 					/* Average marginal effect of CCT */
margins, at(bf=(0 1) race2=(0 1)) 	/* Predicted probabilities by race and CCT */
margins, dydx(bf) at(race2=(0 1)) 	/* Marginal effect of CCT over race */
margins, dydx(race2) at(bf=(0 1)) 	/* Marginal effect of Race over CCT */

* Round 2 - Vote Choice

logit vote2b bf race2 [iweight=cem_weights]
logit vote2b bf race2 educ income female age age2 [iweight=cem_weights]
logit vote2b bf race2 educ income female age age2 i.region [iweight=cem_weights]
logit vote2b c.bf##c.race2 educ income female age age2 i.region [iweight=cem_weights]

logit vote2b c.bf##c.race2 educ income female age age2 i.region [iweight=cem_weights]
margins, dydx(bf) 					/* Average marginal effect of CCT */
margins, at(bf=(0 1) race2=(0 1)) 	/* Predicted probabilities by race and CCT */
margins, dydx(bf) at(race2=(0 1)) 	/* Marginal effect of CCT over race */
margins, dydx(race2) at(bf=(0 1)) 	/* Marginal effect of Race over CCT */



